import express from 'express';
import * as repairShopRouterController from './repairShop.controller';
import { fileInterceptor, fileProcessor } from './repairShop.middleware';
import { validateLoginData, authGuard, userGuard } from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/repairShop', userGuard, repairShopRouterController.index);

/**
 * 获取内容(按 ID)
 */
router.get('/repairShop/:postId', userGuard, repairShopRouterController.repairShopDetail);

/**
 * 按关键字查询（模糊查询）
 */
router.get('/getRepairShopByKey', repairShopRouterController.selectByKey);

/**
 * 创建内容
 */
router.post('/repairShop', authGuard, repairShopRouterController.store);

/**
 * 更新内容
 */
router.patch('/repairShop/:postId', authGuard, repairShopRouterController.update);

/**
 * 删除内容
 */
router.post('/repairShopDestroy', authGuard, repairShopRouterController.destroy);

/**
 * 修改状态
 */
router.patch('/repairShop', authGuard, repairShopRouterController.status);

/**
 * 上传文件
 */
router.post('/repairShopFiles', authGuard, fileInterceptor, fileProcessor, repairShopRouterController.uploads);

/**
 * 文件服务
 */
router.get('/repairShopFiles/:fileId/serve', repairShopRouterController.serve);

/**
 * 获取文件 ID
 */
router.post('/getRepairShopFilesFilesId', repairShopRouterController.getFileName)

/**
 * 导出路由
 */
export default router;
